package stateKit;

import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
public class StateTime{
    private Date startTime;
    private Date endTime;
    private Long intervalMs;

    public StateTime(Date startTime, Date endTime, Long intervalMs) {
        this.startTime = startTime;
        this.endTime = endTime;
        this.intervalMs = intervalMs;
    }

    public StateTime(Long startTime, Long endTime) {
        this(new Date(startTime), new Date(endTime), -1L);
    }

    public List<StateTime> getSonStateTimeList(){
        List<StateTime> list = new ArrayList<>();
        long et = endTime.getTime();
        for(long st = startTime.getTime(); st<et; st+=intervalMs){
            list.add(new StateTime(st, st+intervalMs));
        }
        return list;
    }

    public long getStartTimeMilliSecond(){
        return startTime.getTime();
    }

    public long getStartTimeSecond(){
        return startTime.getTime() / 1000L;
    }

    public long getEndTimeMilliSecond(){
        return endTime.getTime();
    }

    public long getEndTimeSecond(){
        return endTime.getTime() / 1000L;
    }
}